//
//  OldPhotoCardView.m
//  OldPhoto
//
//  Created by 蓝鳍互娱 on 2024/7/29.
//

#import "OldPhotoCardView.h"
@interface OldPhotoCardView()
@property (nonatomic, strong)UILabel * oldPhotoCardNumLab;
@end
@implementation OldPhotoCardView
-(instancetype)init{
    if (self == [super init]) {
        [self creatOldPhotoSubView];
    }
    return self;
}
- (void)creatOldPhotoSubView{
    UIView * oldPhotoCardView = [[UIView alloc] init];
    oldPhotoCardView.backgroundColor = OldPhotoHex(@"#EBF2FD");
    oldPhotoCardView.layer.cornerRadius = OldPhotoRatio(16);
    oldPhotoCardView.clipsToBounds = YES;
    [self addSubview:oldPhotoCardView];
    [oldPhotoCardView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(OldPhotoRatio(24)));
        make.right.equalTo(@(-OldPhotoRatio(24)));
        make.top.equalTo(@(OldPhotoRatio(0)));
        make.height.equalTo(@(OldPhotoRatio(106)));
    }];
    self.oldPhotoCardNumLab = [[UILabel alloc] init];
    self.oldPhotoCardNumLab.textColor = OldPhotoHex(@"#EBF2FD");
    self.oldPhotoCardNumLab.font = [UIFont systemFontOfSize:OldPhotoRatio(32) weight:UIFontWeightRegular];
    [oldPhotoCardView addSubview:self.oldPhotoCardNumLab];
    [self.oldPhotoCardNumLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(OldPhotoRatio(29)));
        make.top.equalTo(@(OldPhotoRatio(0)));
        make.bottom.equalTo(@(OldPhotoRatio(0)));
    }];
    UIButton * oldPhotoCardNumAddBtn = [[UIButton alloc] init];
    [oldPhotoCardNumAddBtn setTitle:@"+添加" forState:UIControlStateNormal];
    [oldPhotoCardNumAddBtn setTitleColor:OldPhotoHex(@"#595BF6") forState:UIControlStateNormal];
    oldPhotoCardNumAddBtn.titleLabel.font = [UIFont systemFontOfSize:OldPhotoRatio(28) weight:UIFontWeightRegular];
    [oldPhotoCardNumAddBtn addTarget:self action:@selector(oldPhotoCardNumAdd) forControlEvents:UIControlEventTouchUpInside];
    [oldPhotoCardView addSubview:oldPhotoCardNumAddBtn];
    [oldPhotoCardNumAddBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@(OldPhotoRatio(0)));
        make.top.equalTo(@(OldPhotoRatio(0)));
        make.bottom.equalTo(@(OldPhotoRatio(0)));
        make.width.equalTo(@(OldPhotoRatio(141)));
    }];
}
-(void)setOldPhotoCardNum:(NSString *)oldPhotoCardNum{
    _oldPhotoCardNum = oldPhotoCardNum;
    NSString * oldPhotoCardNumStr = [NSString stringWithFormat:@"已打卡：%@/%@",_oldPhotoCardNum,_oldPhotoCardAllNum];
    NSString *oldPhotoCardNumChange = _oldPhotoCardNum;
    NSRange oldPhotoCardNumRange = [oldPhotoCardNumStr rangeOfString:oldPhotoCardNumChange];
    NSMutableAttributedString *oldPhotoCardNumMut = [[NSMutableAttributedString alloc] initWithString:oldPhotoCardNumStr];
    [oldPhotoCardNumMut addAttribute:NSForegroundColorAttributeName value:OldPhotoHex(@"#33363C") range:NSMakeRange(0,oldPhotoCardNumMut.length)];
    [oldPhotoCardNumMut addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:OldPhotoRatio(32) weight:UIFontWeightRegular] range:NSMakeRange(0,oldPhotoCardNumMut.length)];
    [oldPhotoCardNumMut addAttribute:NSForegroundColorAttributeName value:OldPhotoHex(@"#595CF7") range:oldPhotoCardNumRange];
    self.oldPhotoCardNumLab.attributedText = oldPhotoCardNumMut;
}
- (void)oldPhotoCardNumAdd{
    if (self.OldPhotoCardAddBlock) {
        self.OldPhotoCardAddBlock();
    }
}
@end
